import { Module } from "@nestjs/common";
import { PassportModule } from '@nestjs/passport';
import { JwtModule, JwtModuleOptions } from '@nestjs/jwt';
import { defaultUserConfig } from "./helper";

const jwtModuleRegister =():JwtModuleOptions=>{
   const config= defaultUserConfig()
   const isProd='production'
   const option:JwtModuleOptions={
    secret:config.jwt.secret,
    verifyOptions:{
        ignoreExpiration:!isProd
    }
   }
   if(isProd)option.signOptions.expiresIn=`${config.jwt.token_expired}s`
   return option
}

@Module({
    imports:[PassportModule,JwtModule.registerAsync({useFactory:jwtModuleRegister})],
    exports:[],
    providers:[]
})
export class UserModule {}


